package com.xjk.web.controller.education;

import com.xjk.common.annotation.Log;
import com.xjk.common.core.controller.BaseController;
import com.xjk.common.core.domain.AjaxResult;
import com.xjk.common.core.page.TableDataInfo;
import com.xjk.common.enums.BusinessType;
import com.xjk.common.utils.SecurityUtils;
import com.xjk.common.utils.poi.ExcelUtil;
import com.xjk.education.domain.EduGradeexam;
import com.xjk.education.mapper.EduGradeexamMapper;
import com.xjk.education.service.IEduGradeexamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.util.List;

/**
 * 考试信息Controller
 * 
 * @author xjk
 * @date 2024-07-21
 */
@RestController
@RequestMapping("/education/gradeexam")
public class EduGradeexamController extends BaseController
{
    @Autowired
    private IEduGradeexamService eduGradeexamService;

    /**
     * 查询考试信息列表
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduGradeexam eduGradeexam)
    {
        Long userId = SecurityUtils.getUserId();
        System.out.println(userId);
        startPage();
        List<EduGradeexam> list = eduGradeexamService.selectEduGradeexamList(eduGradeexam);
        return getDataTable(list);
    }

    /**
     * 导出考试信息列表
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:export')")
    @Log(title = "考试信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduGradeexam eduGradeexam)
    {
        List<EduGradeexam> list = eduGradeexamService.selectEduGradeexamList(eduGradeexam);
        ExcelUtil<EduGradeexam> util = new ExcelUtil<EduGradeexam>(EduGradeexam.class);
        util.exportExcel(response, list, "考试信息数据");
    }

    /**
     * 获取考试信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:query')")
    @GetMapping(value = "/{examId}")
    public AjaxResult getInfo(@PathVariable("examId") Long examId)
    {
        return success(eduGradeexamService.selectEduGradeexamByExamId(examId));
    }

    /**
     * 新增考试信息
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:add')")
    @Log(title = "考试信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduGradeexam eduGradeexam)
    {
        return toAjax(eduGradeexamService.insertEduGradeexam(eduGradeexam));
    }

    /**
     * 修改考试信息
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:edit')")
    @Log(title = "考试信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduGradeexam eduGradeexam)
    {
        return toAjax(eduGradeexamService.updateEduGradeexam(eduGradeexam));
    }

    /**
     * 删除考试信息
     */
    @PreAuthorize("@ss.hasPermi('education:gradeexam:remove')")
    @Log(title = "考试信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examIds}")
    public AjaxResult remove(@PathVariable Long[] examIds)
    {
        return toAjax(eduGradeexamService.deleteEduGradeexamByExamIds(examIds));
    }
}
